package com.tepth.maintenancesystem.presenter;

import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.tepth.maintenancesystem.R;

/**
 * Created by LHQ on 2016/11/28.
 */

public class VehicleDetailsAdapter extends PagerAdapter {
    String[] pagerTitle={"未处理","已完成","车辆详情"};
    int[] pagerLayoutId={R.layout.vehicle_untreated,R.layout.vehicle_completed,R.layout.vehicle_details};
    private InitViewPager initView;

    public VehicleDetailsAdapter(InitViewPager initView) {
        this.initView=initView;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = LayoutInflater.from(container.getContext())
                .inflate(pagerLayoutId[position], container, false);
        initView.initViewPager(view,position);
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);

    }

    @Override
    public int getCount() {
        return pagerLayoutId.length;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public String getPageTitle(int position) {
        return pagerTitle[position];
    }

}
